(function(global, document, _fns, $, console) {
  'use strict';

  /*
  
      @name 自动嵌套命名空间
  
      @desc
  
      @author
  
      @access protected
  
      @function _extend
  
      @param {Object} ns 顶级命名空间
  
      @param {string} [nsString = tlns.ns1.ns2.ns3] 基于顶级命名空间要嵌套的命名空间
  
      @returns {Object} 返回嵌套好的对象。
  
      @example
          // " tlns.sample = $.noop; " === " tlns.ns1.ns2.ns3.sample = $.noop; "
          var tlns = _extend(tlns, "tlns.ns1.ns2.ns3");
  
      @todo 将这个函数放入公共函数库中。
   */
  var _extend, exc;
  _extend = function(ns, nsString) {
    var i, parent, parts, pl;
    parts = nsString.split(".");
    parent = ns;
    pl = parts.length;
    i = 0;
    while (i < pl) {
      if (typeof parent[parts[i]] === "undefined") {
        parent[parts[i]] = {};
      }
      parent = parent[parts[i]];
      i++;
    }
    return parent;
  };
  exc = _extend(_fns, "_fns.excute");

  /*
      @desc
  
      @author
  
      @access protected
  
      @function exc._fast_click
   */
  exc.sidebar = function() {
    global.lsBar();
  };

  exc.did = function () {
	  var btnOrder = $('.sec-order-details').find('.btn-keep-paying');
	  var orderType = $('.sec-order-details').find('.btn-keep-paying').attr('orderType');
	  var url_start;
	  if(orderType && orderType == 'promotion'){
	  	url_start = "/member/proOrderStatus/";
	  }else{
	  	url_start = "/member/orderStatus/";
	  }
	  
	  //检查定单是否支付
	  var checkOrderPayStatus = function (orderId, payUrl) {
	  	$.get(url_start+orderId+".htm", function(data) {
	  		if(data === 'true'){
	  			window.location.assign(payUrl);
	  		}else{
	  		  ECar.easyDialog.open({
					container : {
						header : '提示',
						content : '<div style="text-align:center">无效定单!</div>'
					}
				});
	  		}
	  	});
	  	return true;
	  };
	  
	  btnOrder.on('click', function (e) {
		  var that;
		  that = $(this);
		  checkOrderPayStatus(that.data('orderid'), that.data('payurl'));
	  });
  };
  
  /*
      @name 初始化
  
      @desc 所有在 " _fns.excute " 命名空间下定义的函数将被自动运行。
  
      @author
  
      @access protected
  
      @function _fns.init
  
      @param {Object} opts 存放定义好的可任意修改（配置）的行为选项。
   */
  _fns.init = function(opts) {
    var _it;
    for (_it in exc) {
      if (typeof exc[_it] === "function") {
        exc[_it]();
      }
    }
  };
  $(_fns.init);
  /*添加 物流部分 11-18号*/
  (function(){
    var slideSwitch=$(".slide-switch",".logistics-track-box"),
        logItem =$(".log-item",".track-log"),
        trackLog=$(".track-log"),
        trackLogH,
        initHeight;
        initHeight = logItem.eq(0).outerHeight()+logItem.eq(1).outerHeight()+logItem.eq(2).outerHeight();
        
        //判断item会不会
        if(trackLog.children().length>=3){
        	slideSwitch.css("display","inline-block");
			trackLog.css("height",initHeight);
        }
    slideSwitch.on("click",function(){
		
        trackLogH=trackLog.height();
       //track-log信息盒子的高度
       if(trackLogH>initHeight){
		   $(".track-log").css("height",initHeight); 
    	   $(this).text("查看全部状态");
       }else{
    	   $(".track-log").css("height","auto");
    	   $(this).text("收起");
		   
       }
    });
    
    $('#js_vehicle_track .i-radius').hover(function(){
        $(this).parent().addClass('show');
    },function(){
        $(this).parent().removeClass('show');
    });

  })();
  //物流说明
 var logisticsIntro= $(".logistics-intro",".logistics-track-box");
  logisticsIntro.on("click",function(){
	  ECar.easyDialog.open({
			container : {
				header : '提示',
				content : '<div style="text-align:left;width:400px;" >'+'用户取消定单时，当物流已经发运，则由用户承担所产生的所有物流费用。如还未发运，则无需承担。非车辆质量三包问题及运输过程中造成的问题，一经售出，不退不换。'+'</div>'
			}
	  });
  });

  
})(window, document, {}, jQuery, (typeof console !== 'undefined' ? console : void 0));

